package producersConsumersTests.InserterThroughput;

import prod_cons.TaskContainer;
import producersConsumersTests.utils.DummyTask;
import producersConsumersTests.utils.DummyTaskFactory;
import producersConsumersTests.utils.Inserter;

/**
 * An inserter which counts how many tasks it inserts.
 *
 */
public class CounterInserter extends Inserter<DummyTask> {
	private volatile long taskCounter = 0;
	
	public CounterInserter(TaskContainer container, int peakLength,
			int timeBetweenPeaks) {
		super(container, peakLength, timeBetweenPeaks, new DummyTaskFactory());
	}
	
	public CounterInserter(TaskContainer container, double lambda) {
		super(container, lambda, new DummyTaskFactory());
	}

	@Override
	public void afterInsert(DummyTask task) {
		taskCounter++;
	}

	public long getNumTasks() {
		return taskCounter;
	}

	public void zeroCounter() {
		taskCounter = 0;
	}
}
